In [10]:
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
In [ ]:
%matplotlib inline
In [11]:
import math
def sinckernel(x):
if -0.01<x<0.01:
return 1.0
return math.sin(x)/x
In [12]:
v = np.arange(-5,5,0.1)
scalar function applied to a vector generates an error (as expected)
In [17]:
sincv = sinckernel(v)
In [14]:
sinc = np.vectorize( sinckernel )
In [15]:
sincv = sinc( v )
In [16]:
plt.plot(v, sincv);
In [ ]: